const fs = require('fs');
const xml2js = require('xml2js');

const xmlParser = new xml2js.Parser()

var readStream = fs.createReadStream('city.xml');

var data = '';

readStream.on('data', rs => {
    data += rs;
})

readStream.on('end', () => {
    xmlParser.parseString(data, (err, rs) => {
        var strJson = JSON.stringify(rs);
        var writeStream = fs.createWriteStream('city.json');
        writeStream.write(strJson);
        writeStream.close()
    })
})